﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using STLGROUP.Layers.DataAccessLayers;

namespace STLGROUP.Layers.Common
{
    public static class Cache
    {
        #region Variables

        private static QuanLyBanHangEntities _context = new QuanLyBanHangEntities();

        public static QuanLyBanHangEntities Context
        {
            get { return _context; }
            set { _context = value; }
        }

        #endregion

        #region Methods

        public static IQueryable<T> GetDanhMuc<T>()
        {
            dynamic data = null;

            if (typeof(T) == typeof(DT_KhachHang))
            {
                data = Context.DT_KhachHang.ToList<DT_KhachHang>().AsQueryable<DT_KhachHang>();
            }
            if (typeof(T) == typeof(ACL_PhanQuyenNhomNguoiDung))
            {
                data = Context.ACL_PhanQuyenNhomNguoiDung.ToList<ACL_PhanQuyenNhomNguoiDung>().AsQueryable<ACL_PhanQuyenNhomNguoiDung>();
            }
            if (typeof(T) == typeof(ACL_NhomNguoiDung))
            {
                data = Context.ACL_NhomNguoiDung.ToList<ACL_NhomNguoiDung>().AsQueryable<ACL_NhomNguoiDung>();
            }
            if (typeof(T) == typeof(ACL_Module))
            {
                data = Context.ACL_Module.ToList<ACL_Module>().AsQueryable<ACL_Module>();
            }


            return data;

        }

        public static void  CreateNewContext()
        {
            _context = new QuanLyBanHangEntities();
        }
        #endregion
    }
}
